
const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter
// pages/doTi/wrongs_ofStu/wrongs_ofStu.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lis:[],
    page_no:0,
    page_size:10,
    no_more:false,
  },

  tap_detail(e){
    let index = e.currentTarget.id
    let ti_id = this.data.lis[index].ti_id
    var url_data = {
      date_set:this.date_set,
      jg_stu_id:this.jg_stu_id,
      ti_id,
    }
    getApp().get_vibration()
    wx.navigateTo({
      url: '/pages/doTi/wrong_recs/wrong_recs?url_data=' + JSON.stringify(url_data),
    })
  },

  page_init(jg_stu_id, date_set, page_no, page_size){
    console.log('date_set',date_set)
    wx.request({
      url: domainName + '/wrongs_ofStu_init',
      data: {jg_stu_id,date_set,page_no,page_size},...parameter,
      success: res => {
        var lis = res.data.lis
        if(lis.length>0){
          this.setData({
            lis:this.data.lis.concat(lis),
            page_no:this.data.page_no + 1,
          })
        }else{
          this.setData({
            no_more:true
          })
        }
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log('options',options)
    this.jg_stu_id = options.jg_stu_id
    this.date_set = options.date_set
    this.page_init(this.jg_stu_id, this.date_set,this.data.page_no,this.data.page_size)
    let stu_name = options.stu_name
    wx.setNavigationBarTitle({
      title: '【'+ stu_name + '】错题情况',
    })
  },

  onReachBottom(){
    if(!this.data.no_more){
      this.page_init(this.jg_stu_id, this.date_set,this.data.page_no,this.data.page_size)
    }
  },

})